package com.web.Test0;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class SocketSend {
    public static void main(String[] args) throws Exception {
        //创建Socket对象
        DatagramSocket socket = new DatagramSocket();
        byte[] bytes="今天一起玩游戏呀".getBytes();
        InetAddress byName = InetAddress.getByName("LAPTOP-EJGKKHA5");//ip
        //System.out.println(byName);
        int port=10085;//端口
        //打包
        DatagramPacket packet = new DatagramPacket(bytes, bytes.length, byName, port);
        socket.send(packet);
        //System.out.println(packet);
        socket.close();

    }
}
